package com.ruoyi.yljf.controller.AdminController;

import java.util.List;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.yljf.domain.vo.adminVO.PaperTaxonVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yljf.domain.PaperTaxon;
import com.ruoyi.yljf.service.IPaperTaxonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程试卷列表Controller
 * 
 * @author metaee
 * @date 2025-04-25
 */
@RestController
@RequestMapping("/yljf/taxon")
public class PaperTaxonController extends BaseController {
    @Autowired
    private IPaperTaxonService paperTaxonService;

    /**
     * 查询课程试卷列表列表
     */
    @PreAuthorize("@ss.hasPermi('yljf:taxon:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaperTaxon paperTaxon) {
        startPage();
        List<PaperTaxon> list = paperTaxonService.selectPaperTaxonList(paperTaxon);
        List<PaperTaxonVO> resLit = paperTaxonService.handlePaperTaxon(list);

        return getDataTableInfo(resLit,list);
    }

    /**
     * 导出课程试卷列表列表
     */
    @PreAuthorize("@ss.hasPermi('yljf:taxon:export')")
    @Log(title = "课程试卷列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperTaxon paperTaxon) {
        List<PaperTaxon> list = paperTaxonService.selectPaperTaxonList(paperTaxon);
        ExcelUtil<PaperTaxon> util = new ExcelUtil<PaperTaxon>(PaperTaxon.class);
        util.exportExcel(response, list, "课程试卷列表数据");
    }

    /**
     * 获取课程试卷列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('yljf:taxon:query')")
    @GetMapping(value = "/{taxonId}")
    public AjaxResult getInfo(@PathVariable("taxonId") Long taxonId) {
        return success(paperTaxonService.getById(taxonId));
    }

    /**
     * 新增课程试卷列表
     */
    @PreAuthorize("@ss.hasPermi('yljf:taxon:add')")
    @Log(title = "课程试卷列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperTaxon paperTaxon) {
        return toAjax(paperTaxonService.save(paperTaxon));
    }

    /**
     * 修改课程试卷列表
     */
    @PreAuthorize("@ss.hasPermi('yljf:taxon:edit')")
    @Log(title = "课程试卷列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperTaxon paperTaxon) {
        return toAjax(paperTaxonService.updateById(paperTaxon));
    }

    /**
     * 删除课程试卷列表
     */
    @PreAuthorize("@ss.hasPermi('yljf:taxon:remove')")
    @Log(title = "课程试卷列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taxonIds}")
    public AjaxResult remove(@PathVariable Long[] taxonIds) {
        return toAjax(paperTaxonService.removeByIds(Arrays.asList(taxonIds)));
    }
}
